﻿#parse("partials/header.html") #parse("partials/sidebar.html")
<script type="text/javascript">
    $(document).ready(function () {
        function PopupConfirmNewPatient(patientName) {
            $("#dialog:ui-dialog").dialog("destroy");
            $("#dialog-confirm").dialog({
                resizable: false,
                height: 175,
                modal: true,
                buttons: {
                    "Yes": function () {
                        window.location = rooturl + "patientdata/default/patientdetail/?qspatientname=" + patientName;
                    },
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });
        }

        var oTable = $('#datalist').dataTable({
            "bSort": false,
            "sPaginationType": "full_numbers",
            "bProcessing": true,
            "bServerSide": true,

            "sAjaxSource": rooturl + "patientdata/default/tablelist",
            "aoColumns": [
                            { "mDataProp": "Id" },
                            { "mDataProp": "MedicalRecordNumber" },
                            { "mDataProp": "PatientName" },
                            { "mDataProp": "Birthdate" },
                            { "mDataProp": "PhoneNumber" },
                            { "mDataProp": "AddressDesc" }

                        ],
            "aoColumnDefs": [
                                {
                                    "fnRender": function (o) {
                                        return "<center><a class='tooltip' title='select this record' href='" + rooturl + "patientdata/default/patientdetail/?PatientId=" + o.aData['Id'] + "'><img src='/images/Icons/table.png'/></a> </center>";
                                    },
                                    "aTargets": [0]
                                }
                        ],
            "fnServerData": function (sSource, aoData, fnCallback) {
                aoData.push({ "name": "mrn", "value": $('#TextboxMrn').val() });
                aoData.push({ "name": "patientname", "value": $('#TextboxPatientname').val() });
                aoData.push({ "name": "dob", "value": $('#TextboxDob').val() });
                jQuery.ajax({
                    "dataType": 'json',
                    "type": "GET",
                    "url": rooturl + "patientdata/default/tablelist",
                    "data": aoData,
                    "success": function (data) {
                        if (data["iTotalDisplayRecords"] == 0 && data.ExceptionMessage == null) {
                            if (data["patientName"] == null) {
                                data["patientName"] = "";
                            }
                            PopupConfirmNewPatient(data["patientName"]);
                        }
                        if (data.error != null) {
                            OnloadDialog();
                        } 
                        else if (data.ExceptionMessage != null) {
                            alert(data.ExceptionMessage);
                        }
                        fnCallback(data);
                    }
                });
            }
        });

        function checkForEnter(event) {
            if (event.keyCode == 13) {
                if ($("#mws-validate").valid() == true) {
                    oTable.fnDraw();
                }
            }
        }

        $('#TextboxMrn').keypress(checkForEnter);
        $('#TextboxPatientname').keypress(checkForEnter);
        $('#TextboxDob').keypress(checkForEnter);
        $('#buttonSearch').click(function () {
            if ($("#mws-validate").valid() == true) {
                oTable.fnDraw();
            }
        });

    });
    //End Document Ready

    function OnloadDialog() {
        jQuery("#dialog-confirm-timeout").dialog({
            resizable: false,
            draggable: false,
            closeText: 'hide',
            height: 180,
            modal: true,
            buttons: {
                "Ok": function () {
                    try {
                        parent.ReLogin();

                    } catch (e) {
                        window.location = rooturl + "home/default/login/";
                    }
                }
            }
        });

    }
</script>
<!--mws-container Start-->
<style>
    div#datalist_filter 
    {
        display:none;
    }
    div#datalist_length 
    {
        display:none;
    }
    .mws-table thead 
    {
        margin-top:-10px;
    }
</style>
<div id="dialog-confirm-timeout" title="Confirmation" style="display: none">
    <p>
    </p>
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 3px 20px 40px 50px;">
        </span>
        Session has timeout.
        <br />
        Do you want to Re-Login?
</div>
<div id="mws-container" class="clearfix">
    <!-- Inner Container Start -->
    <div class="container">
        <!-- Panels Start -->
        <div class="mws-panel grid_8">
            <div class="title-caption">
                <h5>$headerinformation  - $Lob - Patient Registration</h5>
            </div>
            <div class="mws-panel-header">
                <span class="mws-i-24 i-table-1">Search Patient</span>
            </div>
            <div class="mws-panel-body">
                <div class="mws-panel-toolbar top clearfix">
                    <ul>
                        <li><a class="mws-ic-16 ic-application-view-list" href="/frontoffice/lobselection/?redirectUri=patientdata/default" title="Search">Select LOB</a></li>
                        <li><a class="mws-ic-16 ic-application-view-list" href="/patientdata/default" title="Search">Search
                            Patient</a></li>
                        <li><a class="mws-ic-16 ic-application-view-list" href="/frontoffice/registration/searchdoctor" title="Search">Doctor List
                            </a></li>
                        <li><a class="mws-ic-16 ic-application-view-list" href="/frontoffice/registration/searchappointment" title="Accept">Appointment List
                        </a></li>
                        
                        <li><a class="mws-ic-16 ic-add" href="/patientdata/default/patientdetail" title="Add">
                            New Patient Data Registration</a></li>
                       <!-- <li><a class="mws-ic-16 ic-accept" href="/frontoffice/registration/registrationlist"
                            title="Accept">Registration List</a></li>-->
                    </ul>
                </div>
                <br />
                <div class="mws-form" action="#">
                <!--flag-->
                <form id="mws-validate">
                    <div class="mws-form-inline">
                        <div class="mws-form-row">
                            <label>
                                MR No.</label>
                            <div class="mws-form-item large">
                                <div class="mws-form-cols clearfix">
                                    <div class="mws-form-col-2-8 alpha">
                                        <div class="mws-form-item">
                                            <input id="TextboxMrn" type="text" class="mws-textinput" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="mws-form-row">
                            <label>
                                Patient Name</label>
                            <div class="mws-form-item large">
                                <div class="mws-form-cols clearfix">
                                    <div class="mws-form-col-2-8 alpha">
                                        <div class="mws-form-item">
                                            <input id="TextboxPatientname" name="TextboxPatientname" type="text" class="mws-textinput" value="$Patientname" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="mws-form-row">
                            <label>
                                DOB </label>
                            <div class="mws-form-item large">
                                <div class="mws-form-cols clearfix">
                                    <div class="mws-form-col-2-8 alpha">
                                        <div class="mws-form-item">
                                            <input id="TextboxDob" type="text" class="mws-textinput mws-datepicker indonesianDate" maxlength="10"/> 
                                        </div>
                                    </div>
                                    <div class="mws-form-col-1-8 alpha" style="margin-top: 7px;">
                                           (dd/mm/yyyy)
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <br />
                    <div class="mws-button-row">
                        <input id="buttonSearch" type="button" value="Search" class="mws-button red" />
                    </div>
                    
                </div>
                
                <table cellpadding="0" cellspacing="0" border="0" class="mws-table" id="datalist"
                    width="80%">
                    <thead>
                        <tr>
                            <th style="width: 10px; text-align: center">
                                Actions
                            </th>
                            <th style="width: 120px;text-align: center">
                                MRN
                            </th>
                            <th style="text-align: center">
                                Patient Name
                            </th>
                            <th style="width: 100px;text-align: center">
                                DOB
                            </th>
                            <th style="width: 100px;text-align: center">
                                Mobile
                            </th>
                            <th style="text-align: center">
                                Address
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td colspan="6" class="dataTables_empty">
                                
                            </td>
                        </tr>
                    </tbody>
                </table>
                <!--Flag-->
                </form>
            </div>
        </div>
        <!-- Panels End -->
    </div>

    <div id="dialog-confirm" title="Confirmation" style="display: none">
        <p> 
        </p>
        <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin: 1px 15px 49px 50px;">
            </span>
            No matching data found.
            <br />
            Create new patient?</p>
    </div>
    <!-- Inner Container End -->
</div>
<!--mws-container End-->

#parse("partials/footer.html")